package com.rentcars.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rentcars.entity.Cars;
import com.rentcars.mapper.CarsMapper;
import com.rentcars.service.CarShareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zezhao
 */
@Service("carShareService")
public class CarShareServiceImpl implements CarShareService {

    @Autowired
    private CarsMapper carsMapper;
    @Override
    public boolean insert(Cars record) {
        return carsMapper.insert(record)>0;
    }

    @Override
    public Cars selectByPrimaryKey(String carid) {
        return carsMapper.selectByPrimaryKey(carid);
    }

    @Override
    public Cars selectByPrimaryKey2(String carid) {
        Cars cars=carsMapper.selectByPrimaryKey2(carid);
        return cars;
    }

    @Override
    public PageInfo<Cars>  selectAll(String carcode, String mobile, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Cars> carsList = carsMapper.selectAll(carcode, mobile);
        PageInfo<Cars> page=new PageInfo<>(carsList);
        return page;
    }

    @Override
    public PageInfo<Cars> searchPutawayCars(String carcode, String mobile,Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        List<Cars> cars=carsMapper.searchPutawayCars(carcode,mobile);
        PageInfo<Cars> page=new PageInfo<>(cars);
        return page;
    }

    @Override
    public boolean updateByPrimaryKey(Cars record) {
        return carsMapper.updateByPrimaryKey(record)>0;
    }

    @Override
    public boolean updateByPrimaryKeySelective(Cars record) {
        return carsMapper.updateByPrimaryKeySelective(record)>0;
    }

    @Override
    public boolean insertSelective(Cars record) {
        return carsMapper.insertSelective(record)>0;
    }
}
